package com.code.generator;


import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author chw
 * @date 2025/3/30
 */
public class ConvertFunc {

    /**
     * json2 wine 项
     *
     * @param json           JSON 格式
     * @param costDetailCode 成本明细代码
     * @return {@link List }<{@link WineItemVO }>
     */
    public static List<WineItemVO> json2WineItem(String json, String costDetailCode) {
        if (StrUtil.isNotBlank(json)) {
            List<WineItemVO> tastingDetailList = JSONUtil.toList(JSONUtil.parseArray(json), WineItemVO.class);
            tastingDetailList.forEach(wine ->
                    wine.setCostDetailCode(costDetailCode));
            return tastingDetailList;
        }
        return new ArrayList<>(1);
    }
}
